﻿
Namespace SQLDataAccess

    ''' <summary>
    ''' Custom application exception class used by the data access layer for packaging all exceptions throw by the data access layer
    ''' </summary>
    ''' <remarks></remarks>
    Public Class DataAccessException
        Inherits Exception

#Region " Declarations & Enums "

        Private _enumReturnCode As DatabaseReturnCode = DatabaseReturnCode.NotSet

#End Region

#Region " Properties "

        Public Property ReturnCode() As DatabaseReturnCode
            Get
                Return _enumReturnCode
            End Get
            Set(ByVal Value As DatabaseReturnCode)
                _enumReturnCode = Value
            End Set
        End Property

#End Region

#Region " Constructors and Load & Unload "

        ''' <summary>
        ''' Initializes as new instance of the DataAccessException class
        ''' </summary>
        ''' <param name="strSource">Calling routine name.  Data Access Layer will be prepended to the name supplied.</param>
        ''' <param name="strMessage">Exception message</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal enumReturnCode As DatabaseReturnCode, ByVal strSource As String, ByVal strMessage As String)
            MyBase.New(strMessage)
            MyBase.Data.Add("Source", String.Concat("Data Access Layer : ", strSource))
            _enumReturnCode = enumReturnCode
        End Sub

        ''' <summary>
        ''' Initializes as new instance of the DataAccessException class
        ''' </summary>
        ''' <param name="strSource">Calling routine name.  Data Access Layer will be prepended to the name supplied.</param>
        ''' <param name="strMessage">Exception message</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal enumReturnCode As DatabaseReturnCode, ByVal strSource As String, ByVal strMessage As String, ByVal exInnerException As Exception)
            MyBase.New(strMessage, exInnerException)
            MyBase.Data.Add("Source", String.Concat("Data Access Layer : ", strSource))
            _enumReturnCode = enumReturnCode
        End Sub

#End Region

    End Class

End Namespace
